package com.construction.base_lib.net.interceptor

import android.text.TextUtils
import okhttp3.Interceptor
import okhttp3.Response

/**
 * @author: FiDo
 * @date: 2024/3/11
 * @des:
 */
class TokenHeaderInterceptor : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        var request = chain.request()
        val headers = request.headers
        var token = headers["token"]
        if (TextUtils.isEmpty(token)) {
            token = "123456"
            request = request.newBuilder().addHeader("token", token).build()
        }
        return chain.proceed(request)
    }

}
